package com.geovis.emergency.spd.biz.resources.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.geovis.emergency.spd.biz.resources.mapper.BsShyjjydwMapper;
import com.geovis.emergency.spd.biz.resources.service.BsShyjjydwService;
import com.geovis.emergency.spd.entity.resources.dto.BsShyjjydwDetailDTO;
import com.geovis.emergency.spd.entity.resources.dto.ResourceListDTO;
import com.geovis.emergency.spd.entity.resources.entity.BsShyjjydw;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Service
@RequiredArgsConstructor
@DS("buffer")
public class BsShyjjydwServiceImpl  extends ServiceImpl<BsShyjjydwMapper, BsShyjjydw> implements BsShyjjydwService {
    @Override
    public List<ResourceListDTO> getShyjjydw() {
        List<BsShyjjydw> shyjjydws=this.list();

        return shyjjydws.stream().map(dw->{
            ResourceListDTO listDTO=new ResourceListDTO();
            BeanUtils.copyProperties(dw,listDTO);
            listDTO.setTitle(dw.getTeamName())
                    .setTypeName("救援力量");
            return listDTO;
        }).collect(Collectors.toList());
    }

    @Override
    public BsShyjjydwDetailDTO getShyjjydwDetail(String id) {
        BsShyjjydw shyjjydw=this.getById(id);

        BsShyjjydwDetailDTO detailDTO=new BsShyjjydwDetailDTO();
        detailDTO.setDq("城阳区")
                .setDwmc(shyjjydw.getTeamName())
                .setFzr(shyjjydw.getMaster())
                .setDwrs(shyjjydw.getTeamNum().toString())
                .setLxfs(shyjjydw.getPhoneNo())
                .setSzdd(shyjjydw.getAddress());
        return detailDTO;
    }
}
